<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 * @author   howe <howe1995@163.com>
 */
use Hyperf\Database\Migrations\Migration;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Schema\Schema;

return new class() extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('files', function (Blueprint $table) {
            $table->id();
            $table->string('name', 50)->default('');
            $table->enum('type', ['file', 'video', 'image', 'audio'])->default('image')->comment('文件类型');
            $table->string('path', 255)->default('')->comment('文件路径');
            $table->string('thumbnail_path', 255)->default('');
            $table->string('format', 20)->default('')->comment('文件格式');
            $table->string('signature', 32)->default('')->unique('uk_signature')->comment('文件唯一标识');
            $table->integer('size')->unsigned()->default(0)->comment('文件大小');
            $table->integer('width')->unsigned()->default(0)->comment('图片宽度');
            $table->integer('height')->unsigned()->default(0)->comment('图片高度');
            $table->integer('duration')->unsigned()->default(0)->comment('视频时长');
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->useCurrent();
            $table->comment('文件表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('files');
    }
};
